package com.dragon.queue;

import java.util.PriorityQueue;

/**
 * 优先队列测试案例
 *
 * @author dragon
 * @since 2020/1/1
 */
public class PriorityQueueTest {

    public static void main(String[] args) {
        PriorityQueue<Person> queue = new PriorityQueue<>((p1, p2) -> p2.name.compareTo(p1.name));
        Person dragon = new Person("dragon");
        Person hero = new Person("hero");
        Person mars = new Person("mars");
        queue.offer(dragon);
        queue.offer(hero);
        queue.offer(mars);

        System.out.println(queue.toString());
    }


    private static class Person {

        private String name;

        public Person(String name) {
            this.name = name;
        }

        public Person() {
        }

        @Override
        public String toString() {
            return "Person{" +
                    "name='" + name + '\'' +
                    '}';
        }
    }
}
